const TerserPlugin = require('terser-webpack-plugin')
const path = require('path')
const resolve = dir => path.resolve(__dirname, dir)

module.exports = {
  publicPath: './',
  lintOnSave: true,
  productionSourceMap: false,

  chainWebpack: config => {
    config.resolve.alias.set('~', resolve('public'))
  },

  configureWebpack: config => {
    if (process.env.NODE_ENV !== 'development') {
      config.optimization.minimize = true
      config.optimization.minimizer = [
        new TerserPlugin({
          extractComments: false,
          terserOptions: {
            compress: {
              warnings: false,
              drop_debugger: false,
              drop_console: true
            },
            sourceMap: false,
            parallel: true
          }
        })
      ]
    }
  }
}
